package com.wang.designPattern.abstractFactory;

import com.wang.designPattern.factory.Shape;
import com.wang.designPattern.factory.ShapeType;

/**
 * @description
 * @Author wangzilong
 * @Date 2025/1/13 7:58
 */
public class AbstractFactoryPatternTest {
    public static void main(String[] args) {
        // 获取形状工厂
        AbstractFactory shapeFactory = FactoryProducer.getFactory("SHAPE");

        Shape circle = shapeFactory.getShape(ShapeType.CIRCLE);
        circle.draw();

        Shape rectangle = shapeFactory.getShape(ShapeType.RECTANGLE);
        rectangle.draw();

        Shape square = shapeFactory.getShape(ShapeType.SQUARE);
        square.draw();
        // 获取颜色工厂
        AbstractFactory colorFactory = FactoryProducer.getFactory("COLOR");

        Color red = colorFactory.getColor(ColorEnum.RED);
        red.fill();

        Color green = colorFactory.getColor(ColorEnum.GREEN);
        green.fill();

        Color yellow = colorFactory.getColor(ColorEnum.YELLOW);
        yellow.fill();
    }
}
